import Vue from "vue";
import Vuex from "vuex";
import axios from '../assets/js/http'

Vue.use(Vuex);

const OK = '001'; // 请求成功状态码

export default new Vuex.Store({
  state: {
    count: 0,
    navUrl: null, // 导航栏路径
    userUrl: null, // 我的账户 导航栏
    loginStatus: false, //登录状态
    accountTabActive: 0, // 我的账户 - 账户信息 点击第几个tab
    isBindPhone: false, // 是否绑定手机
    coinTabActive: 0, // 充币 提币 点击第几个 tab
    tradeTabActive: 0, // 充币 提币 点击第几个 tab
    ifTradePwd: false, // 是否存在交易密码
    ifLoading: false,

   
    
    bbs_user_nav:"",  // 币吧 个人中心导航

    isMe:false,    // 币吧 是否是访客

    // 币币交易
    getBuyPriceData:[],  //最新买卖价格
    
  },
  
  mutations: {
  
    increment(state) {
      state.count++;
    },
    navUrlChange(state, url) {
      state.navUrl = url;
    },
    userUrlChange(state, url) {
      state.userUrl = url;
    },
    loginChange(state, flag) {
      //改变登录状态
      state.loginStatus = flag ? true : false;
    },
    accountTabActiveChange(state, index) {
      state.accountTabActive = index;
    },
    isBindPhoneChange(state, flag) {
      state.isBindPhone = flag ? true : false;
    },
    coinTabActiveChange(state, index) {
      state.coinTabActive = index;
    },
    tradeTabActiveChange(state, index) {
      state.tradeTabActive = index;
    },
    ifTradePwdChange(state, flag) {
      state.ifTradePwd = flag;
    },
    ifLoadingChange(state, flag) {
      state.ifLoading = flag;
    },
    BBS_USER_NAV_CHANGE(state,url) {
      state.bbs_user_nav = url;
    },
    IS_ME(state,flag){
      state.isMe = flag;
    },


  },
  
  actions: {
    //异步处理
    loginChange({ commit }, flag) {
      //异步改变登录状态
      commit("loginChange", flag);
    },
    accountTabActiveChange({ commit }, index) {
      commit("accountTabActiveChange", index);
    },
    isBindPhoneChange({ commit }, flag) {
      commit("isBindPhoneChange", flag);
    },
    coinTabActiveChange({ commit }, index) {
      commit("coinTabActiveChange", index);
    },
    ifLoadingChange({ commit }, flag) {
      commit("ifLoadingChange", flag);
    }


  }
});
